<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<script src="../../2.jq/jquery/jquery-1.12.4.min.js"></script>
<body>
    <button class="btn">点击按钮发送ajax请求</button>
    <script>
     /*    $('.btn').click(()=>{
            let p1 = new Promise((resolve,reject)=>{
            $.ajax({
                method:'get',
                url:'http://localhost:3000/search_info',
                success:(data)=>{
                    console.log(data);
                    resolve(data);
                },
                error:err=>{
                    console.log(err);
                    reject(err);
                }
            })
        })
        p1.then(data=>{
            console.log(data);
            // 
        })
        p.catch(err=>{
            console.log(err);
        })
        }) */
      
        let p1 = new Promise((resolve,reject)=>{
            $.ajax({
                method:'get',
                url:'http://localhost:3000/search_info',
                success:(data)=>{
                    // console.log(data);
                    resolve(data);
                },
                error:err=>{
                    // console.log(err);
                    reject(err);
                }
            })
        })
        $('.btn').click(async()=>{
            let result = await p1;
            console.log(result);
        })
    </script>
</body>
</html>